package com.leyou.item.web;


import com.leyou.item.pojo.Category;
import com.leyou.item.pojo.SpecGroup;
import com.leyou.item.pojo.SpecParam;
import com.leyou.item.service.SpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author:yanjizhw@163.com
 * @date:2019-10-03 12:09
 * 描述:
 * @since:1.0.0
 */
@RestController
@RequestMapping("spec")
public class SpecController {

    @Autowired
    private SpecService specService;

    @RequestMapping("querySpecGroup")
    public ResponseEntity<List<SpecGroup>> querySpecGroup(SpecGroup specGroup){

        List<SpecGroup> groups = specService.querySpecGroup(specGroup);

        return ResponseEntity.ok(groups);
    }

    @RequestMapping("querySpecParam")
    public ResponseEntity<List<SpecParam>> querySpecParam(SpecParam specParam){

        List<SpecParam> groups = specService.querySpecParam(specParam);

        return ResponseEntity.ok(groups);
    }

    @PostMapping("addGroup")
    public String addGroup(SpecGroup specGroup){

        specService.addGroup(specGroup);
        return "spec";
    }

    @PostMapping("modifyGroup")
    public String modifyGroup(SpecGroup specGroup){

        specService.modifyGroup(specGroup);
        return "spec";
    }

    @RequestMapping("moveSpecGroup")
    public String moveSpecGroup(SpecGroup specGroup){

        specService.moveSpecGroup(specGroup);

        return "spec";
    }

    @PostMapping("addParam")
    public String addParam(SpecParam specParam){

        specService.addParam(specParam);
        return "spec";
    }
}
